package com.example.rbacmanage.service.app.impl;

import com.example.rbacmanage.entity.app.UserActivity;
import com.example.rbacmanage.mapper.app.UserActivityMapper;
import com.example.rbacmanage.service.app.UserActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserActivityServiceImpl implements UserActivityService {
    @Autowired
    private UserActivityMapper userActivityMapper;
    @Override
    public void save(UserActivity userActivity) {
        userActivity.setCreateTime(new Date());
        userActivityMapper.insert(userActivity);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            userActivityMapper.del(id);
        }
    }

    @Override
    public void update(UserActivity userActivity) {
        userActivityMapper.update(userActivity);
    }

    @Override
    public List<UserActivity> getAll(UserActivity userActivity) {
        return userActivityMapper.list(userActivity);
    }

    @Override
    public PageInfo<UserActivity> getPage(UserActivity userActivity) {
        PageHelper.startPage(userActivity.getPage(),userActivity.getLimit());
        return new PageInfo<>(getAll(userActivity));
    }

    @Override
    public UserActivity getById(Long id) {
        return userActivityMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(UserActivity userActivity) {
        return userActivityMapper.count(userActivity);
    }
}
